//
//  CheckDemoVC.m
//  设计模式
//
//  Created by huyang on 2020/7/6.
//  Copyright © 2020 test. All rights reserved.
//

#import "CheckDemoVC.h"
#import "Person.h"
#import "NameCheck.h"
#import "SexCheck.h"
#import "AgeCheck.h"
#import "PhoneCheck.h"


@interface CheckDemoVC ()
@property (weak, nonatomic) IBOutlet UITextField *name;
@property (weak, nonatomic) IBOutlet UITextField *sex;
@property (weak, nonatomic) IBOutlet UITextField *age;
@property (weak, nonatomic) IBOutlet UITextField *phone;




@end

@implementation CheckDemoVC

- (void)viewDidLoad {
    [super viewDidLoad];
}

- (IBAction)djBtn:(UIButton *)sender {
    Person *p = [Person new];
    p.name = self.name.text;
    p.age = self.age.text;
    p.sex = self.sex.text;
    p.phone = self.phone.text;
    
    
    NameCheck *name_check = [NameCheck new];
    
    SexCheck *sex_check = [SexCheck new];
    name_check.nextCheck = sex_check;
    
    AgeCheck *age_check = [AgeCheck new];
    sex_check.nextCheck = age_check;
    
    PhoneCheck *phone_check = [PhoneCheck new];
    age_check.nextCheck = phone_check;
    
    phone_check.block = ^(BOOL isSucces) {
        if (isSucces) {
            NSLog(@"登记成功");
        }
    };
    
    
    [name_check handleCheck:p];
    
}


@end
